home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / assemblr / library / sampler0 / load.asm < prev    next >
Assembly Source File  |  1987-05-05  |  3KB  |  121 lines

  1.  
  2.     name     load
  3.     page     55,128
  4.     title    'LOAD -- load .COM file    for MS-DOS 2.0'    
  5. ;
  6. ;
  7. ; LOAD -- load .COM file bigger    than 64K
  8. ; Requires MS-DOS 2.0
  9. ; Version 1.1    Dec 83 RGD
  10. ; Version 1    March 1983 RJW
  11.  
  12. ; copyright (c)    1983
  13. ; Laboratory Microsystems
  14. ; 4147 Beethoven Street
  15. ; Los Angeles, CA  90066
  16. ;
  17. cr    equ    0dh    ;ASCII carriage    return
  18. lf    equ    0ah    ;ASCII line feed
  19.  
  20. cseg    segment    byte
  21.  
  22.     org    100h
  23.  
  24.     assume    cs:cseg,ds:cseg
  25.  
  26. load    proc    far        ; sets up far return ...
  27.  
  28.     push    es        ; save segment of PSP
  29.     mov    dx,offset mes2    ; startup message
  30.     mov    ah,9
  31.     int    21h
  32.     xor    dx,dx        ; zero DX
  33.     mov    ah,25h        ; set terminate    address    ...
  34.     mov    al,22h        ; ... for new program segment
  35.     int    21h
  36.  
  37.     mov    dx,offset endofs ; offset to end of this loader
  38.     mov    cl,4        ; no of    bits to    shift
  39.     shr    dx,cl        ; convert byte addr to paragraph
  40.     inc    dx        ; offset of 1st    available segment
  41.     mov    ax,cs        ; current segment to AX
  42.     add    dx,ax        ; actual value of 1st available    segment
  43.     mov    useg,dx        ; save it for later ...
  44.     mov    es,dx        ; ... and for subsequent move
  45.     mov    ah,26h        ; call to DOS
  46.     int    21h        ; create new program segment
  47.  
  48.     mov    si,6ch        ; 2nd param FCB    in current segment
  49.     mov    di,5ch        ; 1st param FCB    in new segment
  50.     mov    cx,0ch        ; byte count for move
  51.     repz movsb        ; copy the filename
  52.  
  53.     mov    ax,cs        ; copy current code seg    ...
  54.     mov    ds,ax        ; ... to DS
  55.     mov    dx,5ch        ; DS:DX    points to FCB of .COM file
  56.     mov    bx,dx        ; make FCB addressible
  57.     mov    byte ptr  9 [bx],'C' ; force COM extension
  58.     mov    byte ptr 10 [bx],'O'
  59.     mov    byte ptr 11 [bx],'M'
  60.     mov    ah,0fh        ; open the .COM    file
  61.     int    21h
  62.     or    al,al        ; test return code
  63.     jnz    load8        ; exit if non-zero
  64.     mov    word ptr 33 [bx],0000 ;    zero the random    
  65.     mov    word ptr 35 [bx],0000 ;    record field in    the FCB
  66.     pop    es        ; get loader's PSP segment
  67.     mov    bx,useg        ; let SS:SP = default buffer of
  68.     mov    ss,bx        ; new PSP
  69.     mov    sp,100h        
  70.     push    es        ; save loader's    PSP again
  71.     add    bx,10h        ; BX = segment of current DTA
  72.     mov    ds,bx        ; set up DS:DX to point    to the DTA
  73.     xor    dx,dx
  74.     mov    ah,1ah        ; set up DOS call and do it
  75.     int    21h
  76.  
  77. load5:    mov    cx,100h        ; number of records of length 80h
  78.     mov    ax,cs        ; copy current CS to DS
  79.     mov    ds,ax
  80.     mov    dx,5ch        ; DS:DH    points to FCB of .COM file
  81.     mov    ah,27h        ; do random block read
  82.     int    21h
  83.     test    al,1        ; end of file?
  84.     jnz    load9        ; yes, so exit
  85.     add    bx,800h        ; increment location of    DTA
  86.     mov    ds,bx        ; copy to DS
  87.     xor    dx,dx        ; DS:DX    now points to next DTA
  88.     mov    ah,1ah        ; set up DOS call to set DTA
  89.     int    21h
  90.     jmp    load5        ; do it    again
  91.  
  92. load8:    mov    dx,offset mes1    ; "file    not found"
  93.     mov    ah,9        ; write    to terminal
  94.     int    21h
  95.     int    20h        ; exit to DOS
  96.  
  97. load9:    mov    ax,useg        ; set up registers for new segment
  98.     mov    ds,ax
  99.     pop    es        ; pass loader's    PSP segment to overlay
  100.     push    ax        ; push new CS onto stack
  101.     mov    ax,100h
  102.     push    ax        ; push offset onto stack
  103.     ret            ; FAR return causes CS:IP to be    set
  104. load    endp
  105.  
  106. mes1    db    cr,lf,
  107.     db    '.COM file not found'
  108.     db    cr,lf,'$'
  109. mes2    db    cr,lf
  110.     db    'Multi-Segment Loader version 1.1 for MS-DOS 2.0'
  111.     db    cr,lf
  112.     db    'Copyright (c) 1983 Laboratory Microsystems Inc.'
  113.     db    cr,lf,'$'
  114.  
  115. useg    dw    0
  116.  
  117. endofs    equ    $
  118.  
  119. cseg    ends            ; end of code segment
  120.  
  121.     end    load